﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.paypal.soap.api;
using ASPDotNetSamples;

public partial class Admin_RefundReceipt : BasePage
{
   
    protected void Page_Load(object sender, EventArgs e)
    {

        TransactionIdentifier.Text = this.TransactionID;
        Amount.Text = this.PaymentAmount;
        SuccessfulRefundPlaceholder.Visible = false;
    }
    protected RefundTransactionResponseType Result
    {
        get
        {
            return (RefundTransactionResponseType)this.PayPalResponse;
        }
    }


    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        this.DataBind();
    }

    protected string RefundType
    {
        get
        {
            return this.Request.QueryString[Constants.REFUND_TYPE_PARAM];
        }
    }

    protected string PaymentAmount
    {
        get
        {
            return this.Request.QueryString[Constants.PAYMENT_AMOUNT_PARAM];
        }
    }



    public override void DataBind()
    {
        Global.is3token = true;
        Session["stage"] = "SandBox";
        SetProfile.SessionProfile = SetProfile.CreateAPIProfile(Constants.API_USERNAME, Constants.API_PASSWORD, Constants.API_SIGNATURE, "", "", "", "", "SandBox", "");
        if (this.TransactionID != null)
        {
            PayPalAPI api = new PayPalAPI();
            this.PayPalResponse = api.RefundTransaction(this.TransactionID, this.RefundType, this.PaymentAmount);
        }
        this.SuccessfulPlaceholder.Visible = this.IsTransactionSuccessful;
        if (this.Result != null && this.IsTransactionSuccessful)
        {
            this.SuccessfulPlaceholder.DataBind();
        }
        base.DataBind();

    }
}
